package com.itlong.cloud.controller.property;

import com.google.common.base.Joiner;
import com.itlong.cloud.POJO.DTO.property.*;
import com.itlong.cloud.POJO.PO.ProjectPO;
import com.itlong.cloud.POJO.PO.RoomInfoPO;
import com.itlong.cloud.POJO.VO.MessageVO;
import com.itlong.cloud.POJO.VO.operate.OperateProjectDetailVO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectMinAvaliableRoomInfoVO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectRoomInfoVO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectRoomSimpleInfoVO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectUnitInfoVO;
import com.itlong.cloud.PlatformConstants;
import com.itlong.cloud.abstracts.BaseController;
import com.itlong.cloud.annotation.AuthAccessRequired;
import com.itlong.cloud.annotation.LoggerInfo;
import com.itlong.cloud.constants.LogDescConstant;
import com.itlong.cloud.enumerate.RoomPhoneNoTypeEnum;
import com.itlong.cloud.enumerate.ecode.BaseErrorCodeEnum;
import com.itlong.cloud.enumerate.ecode.PropertyErrorCodeEnum;
import com.itlong.cloud.project.operate.IOperateProjectServiceClient;
import com.itlong.cloud.project.property.IPropertyRoomInfoServiceClient;
import com.itlong.cloud.project.property.IPropertyUnitInfoServiceClient;
import com.itlong.cloud.thrown.DataAccessException;
import com.itlong.cloud.user.property.IPropertyHouseHoldInfoServiceClient;
import com.itlong.cloud.utils.network.http.HttpProtocolUtil;
import com.itlong.cloud.utils.node.JsonUtil;
import com.itlong.cloud.utils.page.Page;
import com.itlong.cloud.utils.phonenumber.PhoneNoHandlerUtil;
import com.itlong.cloud.utils.words.NumberHandlerUtil;
import com.itlong.cloud.utils.words.StringHandlerUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;

/**
 * <desc>
 *      房屋信息管理控制器
 * </desc>
 *
 * @createDate 2017-09-21
 */
@RestController
@RequestMapping("project/roomInfo")
public class PropertyRoomInfoController extends BaseController {

    private static final Logger LOG = LoggerFactory.getLogger(PropertyRoomInfoController.class);

    private final IPropertyRoomInfoServiceClient iPropertyRoomInfoServiceClient;   //房屋信息服务接口协议提供对象.

    private final IPropertyHouseHoldInfoServiceClient iPropertyHouseHoldInfoServiceClient; //App用户信息服务接口协议提供对象

    private final IPropertyUnitInfoServiceClient iPropertyUnitInfoServiceClient; //单元信息服务接口协议提供对象.


    private final  IOperateProjectServiceClient iOperateProjectServiceClient; //项目信息服务接口协议提供对象.

    @Autowired
    public PropertyRoomInfoController(IPropertyRoomInfoServiceClient iPropertyRoomInfoServiceClient,
                                      IPropertyHouseHoldInfoServiceClient iPropertyHouseHoldInfoServiceClient,
                                      IPropertyUnitInfoServiceClient iPropertyUnitInfoServiceClient,
                                      IOperateProjectServiceClient iOperateProjectServiceClient) {
        this.iPropertyRoomInfoServiceClient = iPropertyRoomInfoServiceClient;
        this.iPropertyHouseHoldInfoServiceClient = iPropertyHouseHoldInfoServiceClient;
        this.iPropertyUnitInfoServiceClient = iPropertyUnitInfoServiceClient;
        this.iOperateProjectServiceClient = iOperateProjectServiceClient;
    }

    /**
     * <desc>
     *      保存单个房屋信息
     * </desc>
     *
     * @param propertyProjectSaveRoomInfoDTO 添加房屋信息数据传输对象
     * @return MessageVO 标准格式化响应结果
     * @author LouisLewis
     * @createDate 2017-09-29
     */
    @LoggerInfo(operateDesc = LogDescConstant.SAVE_ROOMINFO_LOG_DESC)
    @RequestMapping(path = "/save", method = RequestMethod.POST)
    @ResponseBody
    @AuthAccessRequired
    public Object saveRoomInfo(PropertyProjectSaveRoomInfoDTO propertyProjectSaveRoomInfoDTO) {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyProjectSaveRoomInfoDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectSaveRoomInfoDTO.class, request);
             this.printConsoleInfo("开始处理房屋保存逻辑0");
            //判断参数合法性
            if ((null == propertyProjectSaveRoomInfoDTO)) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }

            //项目编号不能为空
            if (StringUtils.isBlank(propertyProjectSaveRoomInfoDTO.getProjectId())) {
                return new MessageVO(PropertyErrorCodeEnum.PUB_PROJECT_ID_EMPTY_ERR.getErrorCode());
            }

            //单元ID不能为空
            if (StringUtils.isBlank(propertyProjectSaveRoomInfoDTO.getUnitId())) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_UNIT_ID_EMPTY_ERR.getErrorCode());
            }

            //房号不能为空
            if (StringUtils.isBlank(propertyProjectSaveRoomInfoDTO.getRoomNum())) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_NUM_EMPTY_ERR.getErrorCode());
            }

            //房号格式非法
            int intRoomNum = StringHandlerUtil.strToIntDef(propertyProjectSaveRoomInfoDTO.getRoomNum(), -1);
            if (intRoomNum != 0){  //房号允许为0
                if (!NumberHandlerUtil.isInRange(intRoomNum, PlatformConstants.MIN_ROOM_NUM, PlatformConstants.MAX_ROOM_NUM)) {
                    return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_NUM_INVALID_ERR.getErrorCode());
                }
            }


            //备注名称过长
            if (!StringUtils.isEmpty(propertyProjectSaveRoomInfoDTO.getRemark()) && propertyProjectSaveRoomInfoDTO.getRemark().length() > PlatformConstants.MAX_ROOM_REMARK_LENGTH) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_REMARK_LENGTH_ERR.getErrorCode());
            }

            //根据项目场景，处理物业房屋的类型 社区场景为住宅1，非社区场景为办公3 社区场景Id固定为1070645309153116160
            OperateProjectDetailVO detailVO = iOperateProjectServiceClient.getDetail(propertyProjectSaveRoomInfoDTO.getProjectId());
            if(StringUtils.isNotBlank(detailVO.getProjectSceneId()) && detailVO.getProjectSceneId().equals("1070645309153116160")){
                propertyProjectSaveRoomInfoDTO.setRoomType(1);
            }else{
                propertyProjectSaveRoomInfoDTO.setRoomType(3);
            }

            //房屋被呼号码排序在有房屋信息的情况下不能为空
            if ((!StringUtils.isBlank(propertyProjectSaveRoomInfoDTO.getPhoneNo()))
                    ||(!StringUtils.isBlank(propertyProjectSaveRoomInfoDTO.getLandlineNo()))
                    ||(!StringUtils.isBlank(propertyProjectSaveRoomInfoDTO.getExtensionNo()))){

                if (null == propertyProjectSaveRoomInfoDTO.getCallOrder()){
                    return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_PHONE_CALL_ORDER_EMPTY_ERR.getErrorCode());
                }
                List<String> orders =  Arrays.asList(propertyProjectSaveRoomInfoDTO.getCallOrder().split(","));
                if (orders.isEmpty()){
                    return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_PHONE_CALL_ORDER_INVALID_ERR.getErrorCode());
                }
                for (String order:orders){
                    int intOrder = StringHandlerUtil.strToIntDef(order,0);
                    if (!NumberHandlerUtil.isInRange(intOrder, RoomPhoneNoTypeEnum.PHONE_NO.getType(),
                            RoomPhoneNoTypeEnum.EXTENSION_NO.getType())){
                        return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_PHONE_CALL_ORDER_INVALID_ERR.getErrorCode());
                    }
                }
            }


            //访客呼叫码（即房屋呼叫代号）是否格式非法
            String roomAlias = propertyProjectSaveRoomInfoDTO.getRoomAlias();
            if (StringUtils.isNotBlank(roomAlias)) {
                int intRoomAlias = StringHandlerUtil.strToIntDef(roomAlias, -1);

                if (!((intRoomNum == 0) && (intRoomAlias == 0))){ //房号为0时允许房屋呼叫号码为0
                    if ((!NumberHandlerUtil.isInRange(intRoomAlias, PlatformConstants.MIN_ROOM_ALIAS,
                            PlatformConstants.MAX_ROOM_ALIAS)
                            || (intRoomAlias == PlatformConstants.INVALID_ALIAS))) {
                        return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_ALIAS_INVALID_ERR.getErrorCode());
                    }
                }

                this.printConsoleInfo("开始处理房屋保存逻辑1");
                //访客呼叫码在当前单元内不允许重复
                if (null != getRoomInfoByRoomAlias(roomAlias,
                        propertyProjectSaveRoomInfoDTO.getUnitId())) {
                    return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_ALIAS_REPEAT_ERR.getErrorCode());
                }
                this.printConsoleInfo("开始处理房屋保存逻辑2");
                if (intRoomAlias == 0){
                    roomAlias = "0000";
                } else    //自动消去房屋被呼号码可能的前置0，如 "0301"->"301", "00301"->"301"
                {
                    roomAlias = roomAlias.replaceAll("^(0+)", "");
                }
                propertyProjectSaveRoomInfoDTO.setRoomAlias(roomAlias);
            }

            this.printConsoleInfo("开始处理房屋保存逻辑3");
            //房号已被当前单元下的其它房屋占用
            if (null != getRoomInfoByRoomNum(propertyProjectSaveRoomInfoDTO.getRoomNum(), propertyProjectSaveRoomInfoDTO.getUnitId())) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_NUM_REPEAT_ERR.getErrorCode());
            }
            this.printConsoleInfo("开始处理房屋保存逻辑4");
            //所属单元不存在，则不允许添加  //减少用户等待时间，暂时取消 2018-02-06
//            PropertyProjectGetUnitInfoDTO propertyProjectGetUnitInfoDTO = new PropertyProjectGetUnitInfoDTO();
//            propertyProjectGetUnitInfoDTO.setUnitId(propertyProjectSaveRoomInfoDTO.getUnitId());
//            PropertyProjectUnitInfoVO propertyProjectUnitInfoVO = iPropertyUnitInfoServiceClient.getOneUnitInfo(propertyProjectGetUnitInfoDTO);
//            if (null == propertyProjectUnitInfoVO){
//                return new MessageVO(PropertyErrorCodeEnum.PROJECT_UNIT_INFO_NOT_EXISTS_ERR.getErrorCode());
//            }
            this.printConsoleInfo("开始处理房屋保存逻辑5");
            //所属楼栋不存在，则不允许添加
//            if (StringUtils.isEmpty(propertyProjectUnitInfoVO.getBuildNum())||StringUtils.isEmpty(propertyProjectUnitInfoVO.getBuildId())){
//                return new MessageVO(PropertyErrorCodeEnum.PROJECT_BUILD_INFO_NOT_EXISTS_ERR.getErrorCode());
//            }
//            propertyProjectSaveRoomInfoDTO.setBuildId(propertyProjectUnitInfoVO.getBuildId());

            this.printConsoleInfo("开始处理房屋保存逻辑6");
            //如果没有访客呼叫码，则自动生成
            if (StringUtils.isBlank(propertyProjectSaveRoomInfoDTO.getRoomAlias())){
                PropertyProjectGetMinAvaliableRoomInfoDTO getMinAvaliableRoomInfoDTO = new PropertyProjectGetMinAvaliableRoomInfoDTO();
                getMinAvaliableRoomInfoDTO.setRoomNum(propertyProjectSaveRoomInfoDTO.getRoomNum());
                getMinAvaliableRoomInfoDTO.setUnitId(propertyProjectSaveRoomInfoDTO.getUnitId());
                getMinAvaliableRoomInfoDTO.setFloorNo(StringHandlerUtil.strToIntDef(propertyProjectSaveRoomInfoDTO.getFloorNum(),
                        StringHandlerUtil.strToIntDef(StringHandlerUtil.copySubStr(propertyProjectSaveRoomInfoDTO.getRoomNum(),0,2),0)));
                PropertyProjectMinAvaliableRoomInfoVO roomInfoVO = iPropertyRoomInfoServiceClient.getMinAvaliableRoomInfo(getMinAvaliableRoomInfoDTO);
                propertyProjectSaveRoomInfoDTO.setRoomAlias(roomInfoVO.getRoomAlias());
            }
            this.printConsoleInfo("开始处理房屋保存逻辑7");
            //对异地手机号码进行可能的补0操作
            String projectCityName = iOperateProjectServiceClient.getProjectCityName(propertyProjectSaveRoomInfoDTO.getProjectId());
//            String phoneNos = this.handleOtherPlacePhoneNum(propertyProjectSaveRoomInfoDTO.getProjectId(), propertyProjectSaveRoomInfoDTO.getPhoneNo());
            String phoneNos = PhoneNoHandlerUtil.handlerPhoneNoLocationAdd0OrSub0(projectCityName,propertyProjectSaveRoomInfoDTO.getPhoneNo());
            if (StringUtils.isNotBlank(phoneNos)) {
                propertyProjectSaveRoomInfoDTO.setPhoneNo(phoneNos);
            }
            this.printConsoleInfo("开始处理房屋保存逻辑8");
            //保存房屋信息
            iPropertyRoomInfoServiceClient.saveRoomInfo(propertyProjectSaveRoomInfoDTO);
            this.printConsoleInfo("开始处理房屋保存逻辑9");
            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode());


        } catch (Exception e) {
            throw new DataAccessException("【物业_项目_房屋信息】保存房屋信息失败", e);
        }
    }

    /**
     * <desc>
     *      房屋二维码授权
     * </desc>
     *
     * @return MessageVO 标准格式化响应结果
     * @author wangzhi
     * @createDate 2019/09/27
     */
    @LoggerInfo(operateDesc = LogDescConstant.UPDATE_ROOMINFO_QR_CODE_AUTH_LOG_DESC)
    @RequestMapping(path = "/qrCodeAuth", method = RequestMethod.POST)
    @ResponseBody
    @AuthAccessRequired
    public Object qrCodeAuth() {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            PropertyRoomQrCodeAuthDTO propertyRoomQrCodeAuthDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyRoomQrCodeAuthDTO.class, request);
            if (propertyRoomQrCodeAuthDTO == null || StringUtils.isBlank(propertyRoomQrCodeAuthDTO.getRoomId())) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (StringUtils.isBlank(propertyRoomQrCodeAuthDTO.getProjectId())) {
                return new MessageVO(PropertyErrorCodeEnum.PUB_PROJECT_ID_EMPTY_ERR.getErrorCode());
            }
            ProjectPO oneProject = iOperateProjectServiceClient.getOneProject(propertyRoomQrCodeAuthDTO.getProjectId());
            if (oneProject.getChargeMode() == null || oneProject.getChargeMode() != 2) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_CHARGE_MODE_ERR.getErrorCode());
            }
            if (!NumberHandlerUtil.isInRange(propertyRoomQrCodeAuthDTO.getChargeMode(), 1, 2)) {
                return new MessageVO(BaseErrorCodeEnum.PARAM_ERR.getErrorCode());
            }
            if (propertyRoomQrCodeAuthDTO.getChargeMode() == 1 && StringUtils.isBlank(propertyRoomQrCodeAuthDTO.getUsableTimes())) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            if (propertyRoomQrCodeAuthDTO.getChargeMode() == 2 && StringUtils.isBlank(propertyRoomQrCodeAuthDTO.getEndTime())) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            iPropertyRoomInfoServiceClient.qrCodeAuth(propertyRoomQrCodeAuthDTO);
            return new MessageVO(propertyRoomQrCodeAuthDTO.getRoomId(), BaseErrorCodeEnum.SUCCESS.getErrorCode());
        } catch (Exception e) {
            throw new DataAccessException("【物业_项目_房屋信息】房屋二维码授权失败", e);
        }
    }

    /**
     * <desc>
     *      修改房屋信息【根据房屋Id（RoomId）】
     * </desc>
     *
     * @param propertyProjectUpdateRoomInfoDTO 修改房屋信息数据传输对象
     * @return MessageVO 标准格式化响应结果
     * @author LouisLewis
     * @createDate 2017-09-30
     */
    @LoggerInfo(operateDesc = LogDescConstant.UPDATE_ROOMINFO_LOG_DESC)
    @RequestMapping(path = "/update", method = RequestMethod.POST)
    @ResponseBody
    @AuthAccessRequired
    public Object updateRoomInfo(PropertyProjectUpdateRoomInfoDTO propertyProjectUpdateRoomInfoDTO) {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyProjectUpdateRoomInfoDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectUpdateRoomInfoDTO.class, request);
            //判断参数合法性
            if (null == propertyProjectUpdateRoomInfoDTO) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }

            //房屋ID不能为空
            if (StringUtils.isBlank(propertyProjectUpdateRoomInfoDTO.getRoomId())) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_ID_EMPTY_ERR.getErrorCode());
            }

            //备注名称过长
            if (!StringUtils.isEmpty(propertyProjectUpdateRoomInfoDTO.getRemark()) && propertyProjectUpdateRoomInfoDTO.getRemark().length() > PlatformConstants.MAX_ROOM_REMARK_LENGTH) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_REMARK_LENGTH_ERR.getErrorCode());
            }
            //根据项目场景，处理物业房屋的类型 社区场景为住宅1，非社区场景为办公3 社区场景Id固定为1070645309153116160
            OperateProjectDetailVO detailVO = iOperateProjectServiceClient.getDetail(propertyProjectUpdateRoomInfoDTO.getProjectId());
            if(StringUtils.isNotBlank(detailVO.getProjectSceneId()) && detailVO.getProjectSceneId().equals("1070645309153116160")){
                propertyProjectUpdateRoomInfoDTO.setRoomType(1);
            }else{
                propertyProjectUpdateRoomInfoDTO.setRoomType(3);
            }

            //房屋被呼号码排序在有房屋信息的情况下不能为空
            if ((!StringUtils.isBlank(propertyProjectUpdateRoomInfoDTO.getPhoneNo()))
                    ||(!StringUtils.isBlank(propertyProjectUpdateRoomInfoDTO.getLandlineNo()))
                    ||(!StringUtils.isBlank(propertyProjectUpdateRoomInfoDTO.getExtensionNo()))){
                if (null == propertyProjectUpdateRoomInfoDTO.getCallOrder()){
                    return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_PHONE_CALL_ORDER_EMPTY_ERR.getErrorCode());
                }
                List<String> orders =  Arrays.asList(propertyProjectUpdateRoomInfoDTO.getCallOrder().split(","));
                if (orders.isEmpty()){
                    return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_PHONE_CALL_ORDER_INVALID_ERR.getErrorCode());
                }
                for (String order:orders){
                    int intOrder = StringHandlerUtil.strToIntDef(order,0);
                    if (!NumberHandlerUtil.isInRange(intOrder, RoomPhoneNoTypeEnum.PHONE_NO.getType(),
                            RoomPhoneNoTypeEnum.EXTENSION_NO.getType())){
                        return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_PHONE_CALL_ORDER_INVALID_ERR.getErrorCode());
                    }
                }
            }
            //房屋信息是否仍然存在（可能已被其它地方删除），不存在则不允许更新
            PropertyProjectGetRoomInfoDTO propertyProjectGetRoomInfoDTO = new PropertyProjectGetRoomInfoDTO();
            propertyProjectGetRoomInfoDTO.setRoomId(propertyProjectUpdateRoomInfoDTO.getRoomId());
            PropertyProjectRoomInfoVO oldPropertyProjectRoomInfoVO = iPropertyRoomInfoServiceClient.getOneRoomInfo(propertyProjectGetRoomInfoDTO);
            if (oldPropertyProjectRoomInfoVO == null) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_INFO_NOT_EXISTS_ERR.getErrorCode());
            }



            //如需更新访客呼叫码，则需对访客呼叫码进行合法性检测
            String newRoomAlias = propertyProjectUpdateRoomInfoDTO.getRoomAlias();
            if (((null != newRoomAlias)&& (newRoomAlias.length() > 0)) ) {
                //访客呼叫码是否格式非法
                int intRoomAlias = StringHandlerUtil.strToIntDef(newRoomAlias, -1);
                int intRoomNum = StringHandlerUtil.strToIntDef(oldPropertyProjectRoomInfoVO.getRoomNum(), -1);
                if (!((intRoomNum == 0) && (intRoomAlias == 0))){ //房号为0时允许房屋呼叫号码为0
                    if ((!NumberHandlerUtil.isInRange(intRoomAlias, PlatformConstants.MIN_ROOM_ALIAS,
                            PlatformConstants.MAX_ROOM_ALIAS)
                            || (intRoomAlias == PlatformConstants.INVALID_ALIAS))) {
                        return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_ALIAS_INVALID_ERR.getErrorCode());
                    }
                }

                //若访客呼叫码出现变更,检查新访客呼叫码是否被占用
                if (!StringHandlerUtil.compareStrWithOutEmpty(oldPropertyProjectRoomInfoVO.getRoomAlias(), newRoomAlias) && null != getRoomInfoByRoomAlias(newRoomAlias, oldPropertyProjectRoomInfoVO.getUnitId())) {
                    return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_ALIAS_REPEAT_ERR.getErrorCode());
                }

                if (intRoomAlias == 0){
                    newRoomAlias = PlatformConstants.CENTER_CALL_CODE;
                } else    //自动消去房屋被呼号码可能的前置0，如 "0301"->"301", "00301"->"301"
                {
                    newRoomAlias = newRoomAlias.replaceAll("^(0+)", "");
                }
                propertyProjectUpdateRoomInfoDTO.setRoomAlias(newRoomAlias);
            }

            //判定是否需要更新云对讲(访客呼叫码，房屋被呼号码、被呼顺序，正背门变化时)，若需更新，底层将进行RabbitMQ通知
            boolean needNotifyIntercom = (
                    (!StringHandlerUtil.compareStrWithOutEmpty(oldPropertyProjectRoomInfoVO.getRoomAlias(), propertyProjectUpdateRoomInfoDTO.getRoomAlias()))
                            || (!StringHandlerUtil.compareStrWithOutEmpty(oldPropertyProjectRoomInfoVO.getPhoneNo(), propertyProjectUpdateRoomInfoDTO.getPhoneNo()))
                            || (!StringHandlerUtil.compareStrWithOutEmpty(oldPropertyProjectRoomInfoVO.getLandlineNo(), propertyProjectUpdateRoomInfoDTO.getLandlineNo()))
                            || (!StringHandlerUtil.compareStrWithOutEmpty(oldPropertyProjectRoomInfoVO.getExtensionNo(), propertyProjectUpdateRoomInfoDTO.getExtensionNo()))
                            || (!StringHandlerUtil.compareStrWithOutEmpty(oldPropertyProjectRoomInfoVO.getCallOrder(), propertyProjectUpdateRoomInfoDTO.getCallOrder()))
                            || (!NumberHandlerUtil.isEqual(oldPropertyProjectRoomInfoVO.getLiftDoorType(), propertyProjectUpdateRoomInfoDTO.getLiftDoorType())));
            propertyProjectUpdateRoomInfoDTO.setNeedNotifyIntercom(needNotifyIntercom);


            //如果没有访客呼叫码，则自动生成
            if (StringUtils.isBlank(propertyProjectUpdateRoomInfoDTO.getRoomAlias())){
                //如果原有访客呼叫码不为空，则优先使用原访客呼叫码
                if (StringUtils.isNotBlank(oldPropertyProjectRoomInfoVO.getRoomAlias())){
                    propertyProjectUpdateRoomInfoDTO.setRoomAlias(oldPropertyProjectRoomInfoVO.getRoomAlias());
                } else{
                    //所属单元不存在，则不允许修改
                    PropertyProjectGetUnitInfoDTO propertyProjectGetUnitInfoDTO = new PropertyProjectGetUnitInfoDTO();
                    propertyProjectGetUnitInfoDTO.setUnitId(propertyProjectUpdateRoomInfoDTO.getUnitId());
                    PropertyProjectUnitInfoVO propertyProjectUnitInfoVO = iPropertyUnitInfoServiceClient.getOneUnitInfo(propertyProjectGetUnitInfoDTO);
                    if (null == propertyProjectUnitInfoVO){
                        return new MessageVO(PropertyErrorCodeEnum.PROJECT_UNIT_INFO_NOT_EXISTS_ERR.getErrorCode());
                    }
                    PropertyProjectGetMinAvaliableRoomInfoDTO getMinAvaliableRoomInfoDTO = new PropertyProjectGetMinAvaliableRoomInfoDTO();
                    getMinAvaliableRoomInfoDTO.setRoomNum(propertyProjectUpdateRoomInfoDTO.getRoomNum());
                    getMinAvaliableRoomInfoDTO.setUnitId(propertyProjectUnitInfoVO.getUnitId());
                    getMinAvaliableRoomInfoDTO.setFloorNo(StringHandlerUtil.strToIntDef(StringHandlerUtil.copySubStr(propertyProjectUpdateRoomInfoDTO.getRoomNum(),0,2),0));
                    PropertyProjectMinAvaliableRoomInfoVO roomInfoVO = iPropertyRoomInfoServiceClient.getMinAvaliableRoomInfo(getMinAvaliableRoomInfoDTO);
                    propertyProjectUpdateRoomInfoDTO.setRoomAlias(roomInfoVO.getRoomAlias());
                }

        }

            //对异地手机号码进行可能的补0操作
            String projectCityName = iOperateProjectServiceClient.getProjectCityName(propertyProjectUpdateRoomInfoDTO.getProjectId());
//            String phoneNo = this.handleOtherPlacePhoneNum(propertyProjectUpdateRoomInfoDTO.getProjectId(), propertyProjectUpdateRoomInfoDTO.getPhoneNo());
            String phoneNo = PhoneNoHandlerUtil.handlerPhoneNoLocationAdd0OrSub0(projectCityName,propertyProjectUpdateRoomInfoDTO.getPhoneNo());
            if (StringUtils.isNotBlank(phoneNo)) {
                propertyProjectUpdateRoomInfoDTO.setPhoneNo(phoneNo);
            }
            //修改房屋信息
            iPropertyRoomInfoServiceClient.updateRoomInfo(propertyProjectUpdateRoomInfoDTO);
            return new MessageVO(propertyProjectUpdateRoomInfoDTO.getRoomId(),BaseErrorCodeEnum.SUCCESS.getErrorCode());
        } catch (Exception e) {
            throw new DataAccessException("【物业_项目_房屋信息】修改房屋信息失败", e);
        }
    }

    /**
     * <desc>
     *      根据条件逻辑删除房屋信息(支持按roomId或unitId或buildId进行删除）
     * </desc>
     *
     * @param propertyProjectRemoveRoomInfoDTO 删除房屋信息数据传输对象
     * @return MessageVO 标准格式化响应结果
     * @author LouisLewis
     * @createDate 2017-09-30
     */
    @LoggerInfo(operateDesc = LogDescConstant.DELETE_ROOMINFO_LOG_DESC)
    @RequestMapping(path = "/delete", method = RequestMethod.POST)
    @ResponseBody
    @AuthAccessRequired
    public Object removeRoomInfo(PropertyProjectRemoveRoomInfoDTO propertyProjectRemoveRoomInfoDTO) {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyProjectRemoveRoomInfoDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectRemoveRoomInfoDTO.class, request);
            //判断参数合法性（必须有楼栋ID或单元ID才允许进行删除）
            if ((null == propertyProjectRemoveRoomInfoDTO)
                    || (StringUtils.isBlank(propertyProjectRemoveRoomInfoDTO.getRoomId()))) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }

            //若房屋下存在住户，不允许删除
            if (checkHasUserInRoom(propertyProjectRemoveRoomInfoDTO.getRoomId(),propertyProjectRemoveRoomInfoDTO.getProjectId())) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_ROOM_HAS_USER_DELETE_ERR.getErrorCode());
            }

            //删除房屋信息
            iPropertyRoomInfoServiceClient.removeRoomInfo(propertyProjectRemoveRoomInfoDTO);
            return new MessageVO(propertyProjectRemoveRoomInfoDTO.getRoomId(),BaseErrorCodeEnum.SUCCESS.getErrorCode());
        } catch (Exception e) {
            throw new DataAccessException("【物业_项目_房屋信息】删除房屋信息失败", e);
        }
    }

    /**
     * <desc>
     *      分页查询房屋信息
     * </desc>
     *
     * @param propertyProjectGetRoomInfoDTO 分页查询房屋信息数据传输对象
     * @return MessageVO 标准格式化响应结果
     * @author LouisLewis
     * @createDate 2017-10-09
     */
    @RequestMapping(path = "getPage", method = RequestMethod.POST)
    @ResponseBody
    public Object getPage(PropertyProjectGetRoomInfoDTO propertyProjectGetRoomInfoDTO) {
        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyProjectGetRoomInfoDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectGetRoomInfoDTO.class, request);
            //判断参数合法性
            if (null == propertyProjectGetRoomInfoDTO) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }

            if (StringUtils.isBlank(propertyProjectGetRoomInfoDTO.getProjectId())) {
                //项目编号不能为空
                return new MessageVO(PropertyErrorCodeEnum.PUB_PROJECT_ID_EMPTY_ERR.getErrorCode());
            }

            Page<PropertyProjectRoomInfoVO> page = iPropertyRoomInfoServiceClient.getPage(propertyProjectGetRoomInfoDTO);
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), page);
        } catch (Exception e) {
            throw new DataAccessException("【物业_项目_房屋信息】分页查询房屋信息失败", e);
        }
        return messageVO;
    }

    /**
     * <desc>
     *      分页查询指定单元下的房屋简单信息（房屋id ,房屋名称）列表
     * </desc>
     *
     * @param propertyProjectGetRoomSimpleInfoDTO 查询房屋简单信息（房屋ID，房屋名称）数据传输对象
     * @return MessageVO 标准格式化响应结果
     * @author LewisLouis
     * @createDate 2017-09-28
     */
    @RequestMapping(path = "/getPageSimpleList", method = RequestMethod.POST)
    @ResponseBody
    public Object getPageRoomSimpleInfoList(PropertyProjectGetRoomSimpleInfoDTO propertyProjectGetRoomSimpleInfoDTO) {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyProjectGetRoomSimpleInfoDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectGetRoomSimpleInfoDTO.class, request);
            //判断参数合法性
            if (null == propertyProjectGetRoomSimpleInfoDTO) {
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }

            //单元ID不能为空
            if ((StringUtils.isBlank(propertyProjectGetRoomSimpleInfoDTO.getUnitId()))) {
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_UNIT_ID_EMPTY_ERR.getErrorCode());
            }
            //分页查询房屋简单信息列表
            Page<PropertyProjectRoomSimpleInfoVO> page = iPropertyRoomInfoServiceClient.getPageRoomSimpleInfoList(propertyProjectGetRoomSimpleInfoDTO);
            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), page);


        } catch (Exception e) {
            throw new DataAccessException("【物业_项目_房屋信息】分页查询房屋简单信息列表失败", e);
        }
    }

    /**
     * <desc>
     *      精确查询，获取单个房屋信息
     * </desc>
     *
     * @param propertyProjectGetRoomInfoDTO 查询房屋信息数据传输对象
     * @return MessageVO 标准格式化响应结果
     * @author LouisLewis
     * @createDate 2017-10-09
     */
    @RequestMapping(path = "getOne", method = RequestMethod.POST)
    @ResponseBody
    @AuthAccessRequired
    public Object getOne(PropertyProjectGetRoomInfoDTO propertyProjectGetRoomInfoDTO) {

        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyProjectGetRoomInfoDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectGetRoomInfoDTO.class, request);
            PropertyProjectRoomInfoVO propertyProjectRoomInfoVO = iPropertyRoomInfoServiceClient.getOneRoomInfo(propertyProjectGetRoomInfoDTO);
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), propertyProjectRoomInfoVO);
        } catch (Exception e) {
            throw new DataAccessException("【物业_项目_房屋信息】精确查询单个房屋信息失败", e);
        }
        return messageVO;
    }

    /**
     * <desc>
     *      查询指定单元下的排除部分房间的其它所有房屋简单信息（房屋ID，房屋名称）数据传输对象
     * </desc>
     *
     * @param propertyProjectGetRoomSimpleInfoExcludeIdsDTO 查询指定单元下的排除部分房间的其它所有房屋简单信息（房屋ID，房屋名称）数据传输对象
     * @return MessageVO 标准格式化响应结果
     * @createDate 2017-10-24
     */
    @RequestMapping(path = "/getSimpleInfoExcludeIds", method = RequestMethod.POST)
    @ResponseBody
    public Object getRoomSimpleInfoExcludeIds(@RequestBody  PropertyProjectGetRoomSimpleInfoExcludeIdsDTO propertyProjectGetRoomSimpleInfoExcludeIdsDTO) {

        MessageVO messageVO;
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyProjectGetRoomSimpleInfoExcludeIdsDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectGetRoomSimpleInfoExcludeIdsDTO.class, request);
            Map<String,Object> result = iPropertyRoomInfoServiceClient.getRoomSimpleInfoExcludeIds(propertyProjectGetRoomSimpleInfoExcludeIdsDTO);
            List<PropertyProjectRoomSimpleInfoVO> propertyProjectRoomSimpleInfoVOS = (List<PropertyProjectRoomSimpleInfoVO>)result.get("list");
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), propertyProjectRoomSimpleInfoVOS);

        } catch (Exception e) {
            throw new DataAccessException("【物业_项目_房屋信息】查询例外简单房屋信息失败", e);
        }
        return messageVO;
    }


    /**
     * <desc>
     *      获取当前单元楼层下可用的房号和访客呼叫码，用于在添加房屋时提示用户。
     * </desc>
     *
     * @param getMinAvaliableRoomInfoDTO 获取最小可用房号和访客呼叫码查询对象
     * @return MessageVO 标准格式化响应结果
     * @author LouisLewis
     * @createDate 2018-01-16
     */
    @RequestMapping(path = "getMinAvaliableRoomInfo", method = RequestMethod.POST)
    @ResponseBody
    public Object getMinAvaliableRoomInfo(PropertyProjectGetMinAvaliableRoomInfoDTO getMinAvaliableRoomInfoDTO){
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        getMinAvaliableRoomInfoDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectGetMinAvaliableRoomInfoDTO.class, request);
        if ((null == getMinAvaliableRoomInfoDTO) ||
                (StringUtils.isBlank(getMinAvaliableRoomInfoDTO.getUnitId()))
                ||(StringUtils.isBlank(getMinAvaliableRoomInfoDTO.getProjectId()))
                ||(null == getMinAvaliableRoomInfoDTO.getFloorNo())){
            return  new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
        }
//        PropertyProjectGetUnitInfoDTO unitInfoDTO = new PropertyProjectGetUnitInfoDTO();
//        unitInfoDTO.setProjectId(getMinAvaliableRoomInfoDTO.getProjectId());
//        unitInfoDTO.setUnitId(getMinAvaliableRoomInfoDTO.getUnitId());
//        PropertyProjectUnitInfoVO unitInfoVO = iPropertyUnitInfoServiceClient.getOneUnitInfo(unitInfoDTO);
//        if (null == unitInfoVO){
//            return  new MessageVO(PropertyErrorCodeEnum.PROJECT_UNIT_INFO_NOT_EXISTS_ERR.getErrorCode());
//        }
        PropertyProjectMinAvaliableRoomInfoVO roomInfoVO = iPropertyRoomInfoServiceClient.getMinAvaliableRoomInfo(getMinAvaliableRoomInfoDTO);
        return  new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),roomInfoVO);
    }

    /**
     * <desc>
     *      根据房号和单元Id精确查询房屋信息
     * </desc>
     *
     * @param roomNum 房号
     * @param unitId  单元Id
     * @return 房屋信息
     * @author LewisLouis
     * @createDate 2017-10-18
     */
    private RoomInfoPO getRoomInfoByRoomNum(String roomNum, String unitId) {
        PropertyProjectGetRoomInfoDTO propertyProjectGetRoomInfoDTO = new PropertyProjectGetRoomInfoDTO();
        propertyProjectGetRoomInfoDTO.setUnitId(unitId);
        propertyProjectGetRoomInfoDTO.setRoomNum(roomNum);
        return iPropertyRoomInfoServiceClient.getOneSimpleRoomInfo(propertyProjectGetRoomInfoDTO);
    }

    /**
     * <desc>
     *      根据访客呼叫码和单元Id精确查询房屋信息
     * </desc>
     *
     * @param roomAlias 访客呼叫码
     * @param unitId    单元Id
     * @return 房屋信息
     * @author LewisLouis
     * @createDate 2017-10-18
     */
    private RoomInfoPO getRoomInfoByRoomAlias(String roomAlias, String unitId) {
        PropertyProjectGetRoomInfoDTO propertyProjectGetRoomInfoDTO = new PropertyProjectGetRoomInfoDTO();
        propertyProjectGetRoomInfoDTO.setUnitId(unitId);
        propertyProjectGetRoomInfoDTO.setRoomAlias(roomAlias);
        return iPropertyRoomInfoServiceClient.getOneSimpleRoomInfo(propertyProjectGetRoomInfoDTO);
    }

    /**
     * <desc>
     *      检查指定房屋下是否存在用户.
     * </desc>
     *
     * @param roomId 房屋ID
     * @return True：存在    false: 不存在
     * @author LewisLouis
     * @createDate 2017-10-18
     */
    private boolean checkHasUserInRoom(String roomId,String projectId) throws Exception {
        Integer intCount = iPropertyHouseHoldInfoServiceClient.getMoveInHouseHoldCount(roomId,projectId);
        return  intCount > 0;
    }


    /**
    * <desc>
    *    处理异地手机，异地手机号会在前面加0.
    * </desc>
    *
    * @param  projectId 项目编号
   * @param  phoneNums 待处理的手机号码列表，逗号分隔
     * @return 已处理的手机号码
    * @author LewisLouis
    * @createDate 2018-01-27
    */
    private String handleOtherPlacePhoneNum(String projectId,String phoneNums){

        String resultPhoneNo = phoneNums;

        if (StringUtils.isBlank(projectId) || StringUtils.isBlank(phoneNums)){
            return resultPhoneNo;
        }

        try {
            String projectCityName = iOperateProjectServiceClient.getProjectCityName(projectId);
            if (StringUtils.isBlank(projectCityName)){
                return resultPhoneNo;
            }

            List<String> phoneList =  Arrays.asList(phoneNums.split(","));
            List<String> phoneResult = new ArrayList<>();
            for (String onePhoneNum:phoneList){
                String phoneCityName = this.getPhoneNumCity(onePhoneNum);
                if (StringUtils.isBlank(phoneCityName)){
                    phoneResult.add(onePhoneNum);
                    continue;
                }
                boolean isLocalPhoneNum = projectCityName.contains(phoneCityName);
                String onePhoneResult = onePhoneNum;
                if (!isLocalPhoneNum){ //如果不是本地手机，首位加0
                    onePhoneResult  = String.format("0%s",onePhoneNum.replaceAll("^(0+)", ""));
                } else{ //如果是本地手机，取消首位加0
                    onePhoneResult  = onePhoneNum.replaceAll("^(0+)", "");
                }
                phoneResult.add(onePhoneResult);
            }
            if (!phoneList.isEmpty()){
                resultPhoneNo =  Joiner.on(",").join(phoneResult);
            }


        } catch (Exception e) {
            LOG.error(String.format("处理异地手机号码：%s失败",phoneNums),e);
            return resultPhoneNo;
        }

        return resultPhoneNo;

    }


    /**
    * <desc>
    *    //向淘宝获取电话号码归属地.
    *    向已购买的接口获取更精确的号码归属地
    *    已提取在工具类PhoneNoHandlerUtil，此方法无用
    * </desc>
    *
    * @param  phoneNum 电话号码
    * @return 电话号码归属地名称
    * @author LewisLouis
    * @createDate 2018-01-27
    */
    private String getPhoneNumCity(String phoneNum){
        String phoneCityName = "";
        String checkPhoneNum = phoneNum.replaceAll("^(0+)", ""); //去掉首位可能存在的0
//        String url = "https://tcc.taobao.com/cc/json/mobile_tel_segment.htm";
//        String arg = String.format("tel=%s",checkPhoneNum);
        String host = "https://api04.aliyun.venuscn.com";
        String path = "/mobile";
        String method = "GET";
        String appcode = "c1924a31f90e4259a8062060a9ad7c0d";
        Map<String, String> headers = new HashMap<>();
        headers.put("Authorization", "APPCODE " + appcode);
        Map<String, String> querys = new HashMap<>();
        querys.put("mobile",checkPhoneNum);

        try {
//            String result =  httpGet(url,arg);
            HttpResponse response = HttpProtocolUtil.doGet(host, path, method, headers, querys);
//            if (StringUtils.isBlank(result)){
//                return phoneCityName;
//            }
//            PhoneZoneResultVO zoneResultVO = JSONObject.parseObject(result,PhoneZoneResultVO.class);
//            if ((null == zoneResultVO) || (StringUtils.isBlank(zoneResultVO.getProvince()))){
//                LOG.error(String.format("获取手机号码:%s归属地失败",phoneNum));
//                return province;
//            }
//            phoneCityName = getProvinceNameByResponeMsg(result);
//            if (StringUtils.isBlank(phoneCityName)) {
//                LOG.error(String.format("从http返回报文:%s 中解析手机号码:%s归属地失败", result, phoneNum));
//                return phoneCityName;
//            }
            if (response != null && response.getEntity() != null) {
                Map<String, Object> jsonToMap = JsonUtil.JsonToMap(EntityUtils.toString(response.getEntity()));
                if (jsonToMap != null && !jsonToMap.isEmpty()){
                    PhoneNumAttributionGroundDTO phoneNumAttributionGroundDTO = JsonUtil.toObject(jsonToMap.get("data").toString(), PhoneNumAttributionGroundDTO.class);
                    if (StringUtils.isNotBlank(phoneNumAttributionGroundDTO.getCity())){
                        phoneCityName = phoneNumAttributionGroundDTO.getCity();
                    }
                    return phoneCityName;
                }
            }
            LOG.info("获取手机号码归属地失败！");

        } catch (Exception e) {
            LOG.error(String.format("获取手机号码:%s归属地异常",phoneNum),e);
            return phoneCityName;
        }
        return phoneCityName;
    }


    /**
    * <desc>
    *    从http返回报文中解析出省级区域名称.
    * </desc>
    *
    * @param  * @param null
    * @return xx
    * @author LewisLouis
    * @createDate 2018-01-27
    */
    private String getProvinceNameByResponeMsg(String responseMsg){

        String provinceName = "";
        if (StringUtils.isBlank(responseMsg)){
            return provinceName;
        }

        String provinceNameTag = "province";
        int provinceNamePos = responseMsg.indexOf(provinceNameTag);
        if (provinceNamePos < 0){
            return provinceName;
        }
        String tmpMsg = StringHandlerUtil.copySubStr(responseMsg,provinceNamePos,responseMsg.length());
        int commaPos = tmpMsg.indexOf(",");
        if (commaPos < 0){
            return tmpMsg;
        }
        provinceName = StringHandlerUtil.copySubStr(tmpMsg,provinceNameTag.length()+1,commaPos - provinceNameTag.length() - 2);
        provinceName = provinceName.replaceAll("'", ""); //去掉首位可能存在的0
       return provinceName;

    }




     /**
     * <desc>
     *    Http Get信息.注意，本接口编码为GBK，为向淘宝获取电话号码归属地专用
     * </desc>
     *
     * @param httpUrl 请求url
      * @param httpUrl 请求参数
     * @return get返回值，若失败，则返回null
     * @author LewisLouis
     * @createDate 2018-01-27
     */
    private String httpGet(String httpUrl, String httpArg)  {
        BufferedReader reader = null;
        String result = null;
        StringBuffer sbf = new StringBuffer();
        httpUrl = httpUrl + "?" + httpArg;
        try {
            URL url = new URL(httpUrl);
            HttpURLConnection connection = (HttpURLConnection) url
                    .openConnection();
            connection.setRequestMethod("GET");
            // 填入apikey到HTTP header
//            connection.setRequestProperty("apikey",  "您自己的apikey");
            connection.connect();
            InputStream is = connection.getInputStream();
            reader = new BufferedReader(new InputStreamReader(is, "GBK"));
            String strRead = null;
            while ((strRead = reader.readLine()) != null) {
                sbf.append(strRead);
                sbf.append("\r\n");
            }
            reader.close();
            result = sbf.toString();
        } catch (IOException e) {
          LOG.error(String.format("Http请求:%s,参数:%s 失败","",""),e);
        }
        return result;
    }


    /**
    * <desc>
    *    打印控制台信息.
    * </desc>
    *
    * @param info 需要打印的信息
    * @return xx
    * @author LewisLouis
    * @createDate 2018-02-06
    */
    private void printConsoleInfo(String info){
        //System.out.println(String.format("【%s】%s", DateFormatUtils.format(new Date(),"HH:mm:ss.SSS"),info));
    }

}
